<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html class="no-js fixed-layout">
<head>
    <title>
        武汉热干面|长乐美食|武汉人最爱的早餐，没有之一
    </title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/Public/vendor/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/Public/vendor/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="/Public/vendor/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/Public/vendor/assets/css/admin.css">
    <link rel="stylesheet" href="/Public/assets/admin/css/common.css">

    
</head>
<body>

<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <strong>长乐美食城</strong>
        <small>后台管理中心</small>
    </div>

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span
            class="am-icon-bars"></span></button>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
            <li><a href="javascript:;"><span class="am-icon-envelope-o"></span> 收件箱 <span
                    class="am-badge am-badge-warning">5</span></a></li>
            <li class="am-dropdown" data-am-dropdown>
                <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
                    <span class="am-icon-users"></span> <?php echo ($_SESSION['user']['username']); ?>管理员 <span class="am-icon-caret-down"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="#"><span class="am-icon-user"></span> 资料</a></li>
                    <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
                    <li><a href="<?php echo U('User/logout');?>"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
            <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span
                    class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
        </ul>
    </div>
</header>


<div class="am-cf admin-main">
    <!-- sidebar start -->
    <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
        <ul class="am-list admin-sidebar-list">
            <li><a href="/admin"><span class="am-icon-home"></span> 首页</a></li>
            <li class="admin-parent">
                <a class="am-cf" data-am-collapse="{target: '#collapse-nav'}"><span class="am-icon-shopping-cart"></span>
                    商城中心 <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
                <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav">
                    <li><a href="<?php echo U('Product/index');?>" class="am-cf"><span class="am-icon-product-hunt"></span> 商品管理<span
                            class="am-badge am-badge-success am-margin-right am-fr"><?php echo ($count['products']); ?></span></a></li>
                    <li><a href="<?php echo U('Category/index');?>"><span class="am-icon-calendar"></span> 分类管理</a></li>
                    <li><a href="<?php echo U('Advert/index');?>"><span class="am-icon-th"></span> 广告管理<span
                            class="am-badge am-badge-secondary am-margin-right am-fr"><?php echo ($count['adverts']); ?></span></a></li>
                    <!--<li><a href="admin-log.html"><span class="am-icon-calendar"></span> 系统日志</a></li>-->
                    <li><a href="<?php echo U('Product/trash');?>"><span class="am-icon-bug"></span> 商品回收站<span
                            class="am-badge am-badge-warning am-margin-right am-fr"><?php echo ($count['trashs']); ?></span></a></li>
                </ul>
            </li>
            <li><a href="admin-table.html"><span class="am-icon-table"></span> 表格</a></li>
            <li><a href="admin-form.html"><span class="am-icon-pencil-square-o"></span> 表单</a></li>
            <li><a href="#"><span class="am-icon-sign-out"></span> 注销</a></li>
        </ul>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-bookmark"></span> 公告</p>
                <p>时光静好，与君语；细水流年，与君同。—— Amaze UI</p>
            </div>
        </div>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-tag"></span> wiki</p>
                <p>Welcome to the Amaze UI wiki!</p>
            </div>
        </div>
    </div>
</div>

    <!-- sidebar end -->

    <!-- content start -->
    
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">商品列表</strong> /
                    <small>Product</small>
                </div>
            </div>

            <hr>

            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a href="<?php echo U('Product/add');?>" class="am-btn am-btn-default"><span
                                    class="am-icon-plus"></span> 新增
                            </a>
                            <button type="button" class="am-btn am-btn-default del_all"><span class="am-icon-trash-o"></span> 删除
                            </button>
                        </div>
                    </div>
                </div>

                <form>
                    <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-form-group">
                            <select data-am-selected="{btnWidth: '50%',  btnStyle: 'secondary', btnSize: 'sm', maxHeight: 360, searchBox: 1}"
                                    name="category_id">
                                <?php if(is_array($categories)): $i = 0; $__LIST__ = $categories;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$category): $mod = ($i % 2 );++$i;?><option value="">所有类别</option>
                                    <option value="<?php echo ($category["id"]); ?>" disabled>
                                        <?php echo ($category["name"]); ?>
                                        <?php if(is_array($category["children"])): $i = 0; $__LIST__ = $category["children"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$child): $mod = ($i % 2 );++$i;?><option value="<?php echo ($child["id"]); ?>">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--<?php echo ($child["name"]); ?>
                                    </option><?php endforeach; endif; else: echo "" ;endif; ?>
                                </option><?php endforeach; endif; else: echo "" ;endif; ?>

                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-input-group am-input-group-sm">
                            <input type="text" name="name" class="am-form-field" placeholder="按商品名称">
                            <span class="am-input-group-btn">
                            <button class="am-btn am-btn-default" type="submit">搜索</button>
                            <a href="<?php echo U('Product/index');?>" class="am-btn am-btn-default">重置</a>
                            </span>
                        </div>
                    </div>
                </form>
            </div>

            <div class="am-g">
                <div class="am-u-sm-12">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-check"><input type="checkbox" class="checked_all"/></th>
                            <th class="table-id">ID</th>
                            <th class="table-title">商品名称</th>
                            <th class="table-type">所属分类</th>
                            <th class="table-author am-hide-sm-only">单价</th>
                            <th class="table-date am-hide-sm-only">库存</th>
                            <th class="table-date am-hide-sm-only">缩略图</th>
                            <th class="table-date am-hide-sm-only">置顶</th>
                            <th class="table-date am-hide-sm-only">新品</th>
                            <th class="table-date am-hide-sm-only">热销</th>
                            <th class="table-date am-hide-sm-only">推荐</th>
                            <th class="table-date am-hide-sm-only">上架</th>
                            <th class="table-date am-hide-sm-only">创建时间</th>
                            <th class="table-date am-hide-sm-only">商品排序</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if(is_array($products)): $i = 0; $__LIST__ = $products;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$product): $mod = ($i % 2 );++$i;?><tr data-id="<?php echo ($product["id"]); ?>">
                                <td><input type="checkbox" name="checked_id[]" class="checked_id"
                                           value="<?php echo ($product["id"]); ?>"/></td>
                                <td class="am-hide-sm-only"><?php echo ($product["id"]); ?></td>
                                <td class="am-hide-sm-only"><?php echo ($product["name"]); ?></td>
                                <td class="am-hide-sm-only"><a href="#"><?php echo ($product["category"]["name"]); ?></a></td>
                                <td class="am-hide-sm-only">
                                    <input type="text" value="<?php echo ($product["price"]); ?>" style="width: 40px;">
                                </td>
                                <td class="am-hide-sm-only">
                                    <input type="text" value="<?php echo ($product["stock"]); ?>" style="width: 40px;">
                                </td>
                                <td class="am-hide-sm-only">
                                    <img src="/Uploads/images/<?php echo ($product["thumb"]); ?>" style="width:80px;height:60px;">
                                </td>
                                <?php if(is_array($datas)): foreach($datas as $key=>$data): ?><td class="">
                                        <?php echo is_something($product,$data);?>
                                    </td><?php endforeach; endif; ?>
                                <td class="am-hide-sm-only"><?php echo (date('Y-m-d h:i:s',$product["create_at"])); ?></td>
                                <td>
                                    <input type="text" value="<?php echo ($product["sort_order"]); ?>" class="sort_order" style="width: 40px;">
                                </td>
                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a href="<?php echo U('edit', ['id'=>$product[id]]);?>"
                                               class="am-btn am-btn-default am-btn-xs am-text-secondary"><span
                                                    class="am-icon-pencil-square-o"></span> 编辑
                                            </a>
                                            <a href="<?php echo U('cyble', ['id'=>$product[id]]);?>" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only">
                                                <span class="am-icon-trash-o"></span> 回收
                                            </a>
                                        </div>
                                    </div>
                                </td>
                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                        </tbody>
                    </table>
                    <div class="am-cf">
                        共 <?php echo ($count['products']); ?> 条记录
                        <div class="am-fr">
                            <ul class="am-pagination">
                                <!--<li class="am-disabled"><a href="#">«</a></li>-->
                                <!--<li class="am-active"><a href="#">1</a></li>-->
                                <!--<li><a href="#">2</a></li>-->
                                <!--<li><a href="#">3</a></li>-->
                                <!--<li><a href="#">4</a></li>-->
                                <!--<li><a href="#">5</a></li>-->
                                <!--<li><a href="#">»</a></li>-->
                                <?php echo ($pages); ?>
                            </ul>
                        </div>
                    </div>
                    <hr/>
                </div>

            </div>
        </div>

        <footer class="admin-content-footer">
            <hr>
            <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
        </footer>

    </div>

    <!-- content end -->

</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
   data-am-offcanvas="{target: '#admin-offcanvas'}"></a>



<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/Public/vendor/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/Public/vendor/assets/js/amazeui.min.js"></script>
<script src="/Public/vendor/assets/js/app.js"></script>


    <script>
        $(function () {
            //全选/反选
            $('.checked_all').click(function () {
                $(':checkbox').prop("checked", this.checked);
            });

            $(".del_all").click(function () {
                var length = $(".checked_id:checked").length;
                if (length == 0) {
                    alert('您至少要选中一条记录');
                    return false;
                }

                if (confirm('确定要移至回收站么？')) {
                    var checked_id = $(".checked_id:checked").serialize();

                    $.ajax({
                        type: "POST",
                        url: "<?php echo U('delete_all');?>",
                        data: checked_id,
                        success: function (data) {
                            if (data.status == 1) {
                                alert(data.msg);
                                window.location.reload();
                            }
                        }
                    })
                }
                return false;
            })
            //AJAX排序
            $(".sort_order").change(function(){
                var id = $(this).parents('tr').data('id');
//                console.log(id);return false;
                var sort_order = $(this).val();
//                console.log(sort_order);return false;
                $.post("<?php echo U('sort_all');?>",{id : id ,sort_order : sort_order},function(){
//                        window.location.reload();
                })
                return false;
            })
            //是否显示
            $('.change_attr').click(function () {
                var id = $(this).parents('tr').data('id');
//                console.log(id);return false;
                var attr = $(this).attr('data-attr');
//                console.log(attr);return false;
                var _this = $(this);
                $.post("<?php echo U('change_attr');?>", {
                    id:id,
                    attr:attr
                }, function () {
                    _this.toggleClass('am-icon-check am-icon-close');
                })
                return false;
            })
//            $.ajax({
//                type: "POST",
//                url: "<?php echo U('sort_all');?>",
//                data: "id,sort_order",
//                success: function (data) {
//                    if (data.status == 1) {
//                        alert(data.msg);
//                        window.location.reload();
//                    }
//                }
//            })

        })
    </script>

</body>
</html>